<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="__STATIC__/web/js/rem.js"></script>
    <link rel="stylesheet" href="__STATIC__/web/css/public.css">
    <link rel="stylesheet" href="__STATIC__/web/css/change_phone.css">
    <script src="__STATIC__/web/js/jquery.js"></script>
    <title>其他设置</title>
</head>

<body>
    <div class="header">

        <if condition="$uid eq null">
            <a href="{:url('login/login')}">
                <img class="login-user" src="__STATIC__/web/img/login_user.png" />
            </a>
            <else/>
            <div class="login">
                <a href="{:url('me/me')}">
                    <img class="login-user" src="__STATIC__/web/img/login_user.png" />
                </a>
            </div>
        </if>
        <img class="logo" src="__STATIC__/web/img/logo_white.png" />
    </div>
    <div class="change-text">换绑手机号</div>
    <div class="input">
        <input type="text" placeholder="原手机号" id="old_phone">
        <div>
            <input type="text" placeholder="新手机号" id="new_phone">
            <button id="get_code">获取验证码</button>
        </div>
        <input type="text" placeholder="验证码" id="phone_code">
    </div>
    <div class="submit" id="submit">
        <button class="submit">确定</button>
    </div>
    <footer>
        <div class="bottom-bar">
            <div>Copyright©2019 　山东科技大学 </div>
            <div>鲁ICP备09051012号</div>
        </div>
    </footer>
    <script src="__PUBLIC__/js/public/jquery-1.11.3.min.js"></script>
    <script src="__PUBLIC__/js/public/swiper.min.js"></script>
    <script src="__PUBLIC__/js/public/bootstrap.min.js"></script>
    <script src="__PUBLIC__/js/layer/layer/layer.js"></script>
<script>

    $("#get_code").click(function () {
        const phone = $("#new_phone").val();
        $.post('getCode',{phone:phone},function (res) {
            console.log(res)
            if (res.code == 0){
                return layer.msg(res.msg);
            }else{
                return layer.msg(res.msg);
            }
        })
    })

    $("#submit").click(function () {
        const oldPhone = $("#old_phone").val();
        const nPhone = $("#new_phone").val();
        const code = $("#phone_code").val();

        $.post('resetPhone',{old:oldPhone,phone:nPhone,code},function (res) {
            return layer.msg(res.msg)
        })
    })
</script>
</body>

</html>